/*
 * Copyright (c) 2008, Xiong Yingfei, the University of Tokyo
 * All rights reserved.
 */
package ac.jp.u_tokyo.SyncLib.language2;

import ac.jp.u_tokyo.SyncLib.SetMembers.NoDefaultValue;
import ac.jp.u_tokyo.SyncLib.language.BooleanConst;
import ac.jp.u_tokyo.SyncLib.language.Const;
import ac.jp.u_tokyo.SyncLib.language.NativeSyncBody;
import ac.jp.u_tokyo.SyncLib.language.NullConst;
import ac.jp.u_tokyo.SyncLib.language.ObjCreation;
import ac.jp.u_tokyo.SyncLib.language.SyncBody;
import ac.jp.u_tokyo.SyncLib.language.factories.DVDGetFactory;
import ac.jp.u_tokyo.SyncLib.language.factories.EqualFactory;
import ac.jp.u_tokyo.SyncLib.language.factories.EqualTester;
import ac.jp.u_tokyo.SyncLib.language.factories.IDFactory;
import ac.jp.u_tokyo.SyncLib.language.factories.KVDGetFactory;
import ac.jp.u_tokyo.SyncLib.language.factories.NotEqualFactory;
import ac.jp.u_tokyo.SyncLib.language.factories.NotEqualTester2;
import ac.jp.u_tokyo.SyncLib.language.factories.SetMembersFactory;
import ac.jp.u_tokyo.SyncLib.language.factories.StaticGetFactory;
import ac.jp.u_tokyo.SyncLib.language.factories.TestEqualFactory;

public class NativeSyncFactory
{
	public static SyncBody createId(boolean v1OverV2, int line) {
		NativeSyncBody result = new NativeSyncBody(line, IDFactory.class.getName(), 2);
		result.addOption("V1OverV2", new BooleanConst(line, v1OverV2));
		return result;
	}
	
	public static SyncBody createEqual(Const value, int line) {
		NativeSyncBody result = new NativeSyncBody(line, EqualFactory.class.getName(), 1);
		result.addOption("Value", value);
		return result;
	}

	public static SyncBody createSGet(Const key, boolean dictOverValue, int line) {
		NativeSyncBody result = new NativeSyncBody(line, StaticGetFactory.class.getName(), 2);
		result.addOption("DictOverValue", new BooleanConst(line, dictOverValue));
		result.addOption("Key", key);
		return result;
	}

	public static SyncBody createEqual2(int line) {
		NativeSyncBody result = new NativeSyncBody(line, SetMembersFactory.class.getName(), 2);
		result.addOption("DefaultValues", new ObjCreation(line, NoDefaultValue.class.getName().replace('$', '.')));
		result.addOption("Tester", new ObjCreation(line, EqualTester.class.getName()));
		return result;
	}

	public static SyncBody createNotEqual2(int line) {
		NativeSyncBody result = new NativeSyncBody(line, SetMembersFactory.class.getName(), 2);
		result.addOption("DefaultValues", new ObjCreation(line, NoDefaultValue.class.getName().replace('$', '.')));
		result.addOption("Tester", new ObjCreation(line, NotEqualTester2.class.getName()));
		return result;
	}

	public static SyncBody createNotEqual(Const value, int line) {
		NativeSyncBody result = new NativeSyncBody(line, NotEqualFactory.class.getName(), 1);
		result.addOption("DefaultValue", new ObjCreation(line, NoDefaultValue.class.getName().replace('$', '.')));
		result.addOption("Value", value);
		return result;
	}

	public static SyncBody createTestEqual(Const value, int line) {
		NativeSyncBody result = new NativeSyncBody(line, TestEqualFactory.class.getName(), 1);
		result.addOption("Value", value);
		return result;
	}

	public static SyncBody createDVDGet(boolean dictOverValue, int line) {
		NativeSyncBody result = new NativeSyncBody(line, DVDGetFactory.class.getName(), 3);
		result.addOption("DictOverValue", new BooleanConst(line, dictOverValue));
		return result;
	}

	public static SyncBody createKVDGet(boolean keyOverValue, boolean changeDict, int line) {
		NativeSyncBody result = new NativeSyncBody(line, KVDGetFactory.class.getName(), 3);
		result.addOption("KeyOverValue", new BooleanConst(line, keyOverValue));
		if (changeDict) 
			result.addOption("KeyFactory", new ObjCreation(line, GlobalIncrementalFactory.class.getName()));
		else
			result.addOption("KeyFactory", new NullConst(line));
		return result;
	}

}
